// HPGDI.h: interface for the CHPGDI class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_HPGDI_H__85BB0A07_7CFD_4254_A8B9_833C6B866229__INCLUDED_)
#define AFX_HPGDI_H__85BB0A07_7CFD_4254_A8B9_833C6B866229__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define DOTLINE 3
struct HPRECT
{
	int left,top,right,bottom;
        short clipRectLine(int *xx1,int *yy1,int *xx2,int *yy2)
        {
        float x1,_y1,x2,y2,q;
        HPRECT r;
        float f;
        r.left=left;
        r.right=right;
        r.top=top;
        r.bottom=bottom;
        x1=*xx1;
        x2=*xx2;
        _y1=*yy1;
        y2=*yy2;
        if(x1<=r.left   && x2<=r.left)        return(0);
        if(x1>=r.right  && x2>=r.right)       return(0);
        if(x1>=r.left   && x1<=r.right && x2>=r.left && x2<=r.right &&
                _y1>=r.top    && _y1<=r.bottom&& y2>=r.top  && y2<=r.bottom)
                return(1);

        if(x1<r.left)
        {
                f=(float)(y2-_y1)/(float)(x2-x1);
                q=(r.left-x1)*f+_y1;
                _y1=q;
                x1=r.left;
        }
        else if(x1>r.right)
        {
                f=(float)(y2-_y1)/(float)(x2-x1);
                q=(r.right-x1)*f+_y1;
                _y1=q;
                x1=r.right;
        }
        if(x2<r.left)
        {
                f=(float)(y2-_y1)/(float)(x2-x1);
                q=(r.left-x1)*f+_y1;
                y2=q;
                x2=r.left;
        }
        else if(x2>r.right)
        {
                f=(float)(y2-_y1)/(float)(x2-x1);
                y2=(r.right-x1)*f+_y1;
                x2=r.right;
        }
        if(_y1<=r.top    && y2<=r.top)         return(0);
        if(_y1>=r.bottom && y2>=r.bottom)      return(0);
        if(_y1<r.top)
        {
                f=(float)(x1-x2)/(float)(_y1-y2);
                x1=(r.top-_y1)*f+x1;
                _y1=r.top;
        }
        else if(_y1>r.bottom)
        {
                f=(float)(x1-x2)/(float)(_y1-y2);
                x1=(r.bottom-_y1)*f+x1;
                _y1=r.bottom;
        }
        if(y2<r.top)
        {
                f=(float)(x1-x2)/(float)(_y1-y2);
                x2=(r.top-_y1)*f+x1;
                y2=r.top;
        }
        else if(y2>r.bottom)
        {
                f=(float)(x1-x2)/(float)(_y1-y2);
                x2=(r.bottom-_y1)*f+x1;
                y2=r.bottom;
        }
        *xx1=x1;
        *xx2=x2;
        *yy1=_y1;
        *yy2=y2;
        return(1);
}
    };
class CHPGDI  
{
public:
	virtual int GetFontHeight();
	virtual int GetStrWidth(char *str);
	virtual void line(int x1,int y1,int x2,int y2,long c){};
	virtual void OutText(int x,int y,char *str,long c){};
	virtual void DrawRect(int left,int top,int right,int bottom,long c){};
        virtual void FillRect(int left,int top,int right,int bottom,long c){};
        virtual void Clear(){};
        virtual void begin(){};
        virtual void end(){};
        virtual void SetLineType(int t){};
        virtual void ResetLineType(){};
	CHPGDI();
	virtual ~CHPGDI();
};

#endif // !defined(AFX_HPGDI_H__85BB0A07_7CFD_4254_A8B9_833C6B866229__INCLUDED_)
